package com.neuosft.his.entity;

public class CommonResult {
	private int  code =  200;
	private String  msg = "success";
	private int  allnum=  1;
	private Object result;
	
	public static final  int GETEMPTY= 201;//  insertFailed
	public static final  int INSERTFAILED= 202;//  insertFailed	
	public static final  int UPDATEFAILED= 203;
	public static final  int DELETEFAILED= 204;
	public static final  int INNEREXCEPTION = 500;
	public static final String RESULT = "result";
	private static final int BADREQUEST = 400;
	public void innerException() {
		this.code = INNEREXCEPTION;
		this.msg="内部异常";
		this.allnum = 0 ;
		this.result = -1;
		
	}
	/**
	 * 向客户端传递信息，表示插入失败
	 */
	public void  insertFailed() {
		this.code = INSERTFAILED;
		this.msg="插入失败";
		this.allnum = 0 ;
		this.result = -1;
	}
	
	public void  updateFailed() {
		this.code = INSERTFAILED;
		this.msg="修改失败";
		this.allnum = 0 ;
		this.result =-1;
	}
	public void  deleteFailed() {
		this.code = DELETEFAILED;
		this.msg="删除失败";
		this.allnum = 0 ;
		this.result =-1;
	}
	/**
	 * 查询已经结束，但是没有满足条件的记录
	 */
	public void  getEmpty() {
		this.code = GETEMPTY;
		this.msg="查询已经结束，但是没有满足条件的记录";
		this.allnum = 0 ;
		this.result = null;
	}
	
	
	public CommonResult() {
		// TODO Auto-generated constructor stub
	}


	public CommonResult(int code, String msg, int allnum, Object result) {
		super();
		this.code = code;
		this.msg = msg;
		this.allnum = allnum;
		this.result = result;
	}
	public CommonResult(  Object result) {		 
		this.result = result;
	}


	public int getCode() {
		return code;
	}


	public void setCode(int code) {
		this.code = code;
	}


	public String getMsg() {
		return msg;
	}


	public void setMsg(String msg) {
		this.msg = msg;
	}


	public int getAllnum() {
		return allnum;
	}


	public void setAllnum(int allnum) {
		this.allnum = allnum;
	}


	public Object getResult() {
		return result;
	}


	public void setResult(Object result) {
		this.result = result;
	}


	@Override
	public String toString() {
		return "CommonResult [code=" + code + ", msg=" + msg + ", allnum=" + allnum + ", result=" + result + "]";
	}

	public void badRequest() {
		this.code  = BADREQUEST;
		this.msg="请求的地址不存在或者包含不支持的参数";
		this.allnum = -1;
		
	}

	
	
	
	
	
	
}
